<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" placeholder="请输入姓名">
    <script>
        window.addEventListener('load',()=>{
            let input = document.getElementsByTagName('input')[0];

            //获得焦点
            input.addEventListener('focus',()=>{
                console.log('输入框获得焦点');
                input.style.width = '600px';
                input.style.height= '40px';
            });
            //失去焦点
            input.addEventListener('blur',()=>{
                console.log('输入框失去焦点')
                input.style.width = '200px';
                input.style.height= '20px';
                input.style.border = '1px solid red';


                //获取输入框中的value值
                console.log(input.value);
            });
        });
    </script>
</body>
</html>